import { getCorrosionData } from "../../api"
import { getCorPredctionData } from "../../api"

let state = {
  corrosionData: [],
  CorPredctionData: []
}

let mutations = {
  // 缺陷-腐蚀数据
  CORROSIONDATA(state, corrosionData) {
    state.corrosionData = corrosionData
  },
  // 缺陷-腐蚀预测
  CORPREDICTIONDATA(state, CorPredictionData) {
    state.CorPredictionData = CorPredictionData
  }
}

let actions = {
  // 缺陷-腐蚀数据
  async corrosionData({ commit, state, dispatch }) {
    let result = await getCorrosionData()
    if(result.code == 200) {
      commit('CORROSIONDATA', result.res)
    }
  },

  // 缺陷-腐蚀预测
  async CorPredictionData({ commit }) {
    let result = await getCorPredctionData()
    if(result.code == 200) {
      commit('CORPREDICTIONDATA', result.res)
    }
  }
}

let getters = {}

export default {
  state,
  mutations,
  actions,
  getters
}